﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Galaxian
{
    public class Projectile : GameObject
    {
        private bool DirectionUp { get; set; }

        public Projectile(Position pos, bool directionUp, bool isEnemy)
            : base(pos, Objects.Projectile, isEnemy)
        {
            this.DirectionUp = directionUp;
            this.isEnemy = isEnemy;
        }

        public override char[,] GetImage()
        {
            if (this.isEnemy)
            {
                return new char[,] { { '*' } };
            }
            else
            {
                return new char[,] { { '^' } };
            }
        }

        public override bool CanCollideWith(Objects obj)
        {
            if (this.isEnemy)
            {
                return obj==Objects.Ship || obj==Objects.Projectile;
            }
            else
            {
                return obj==Objects.Enemy || obj==Objects.Projectile;
            }
            
        }

        public override Position GetPosition()
        {
            return this.Position;
        }

        // Automatic movement
        public void AutoMove()
        {
            if (this.DirectionUp)
            {
                this.Position.X--;
            }
            else
            {
                this.Position.X++;
            }
        }

        public override void Update()
        {
            this.AutoMove();
        }
    }
}
